﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using A2DFramework.AssemblyService;

namespace A2DFramework.EsbService.DistributedEsb.Configuration
{
    public static class DistributedEsbConfiguration
    {
        public static bool WebSessionSupport;

        static DistributedEsbConfiguration()
        {
            //load setings from xml file
            XElement root = XElement.Load(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "A2D.config"));

            root = root.Element("EsbSetting");
            if (root == null)
                throw new Exception("EsbSetting node not exists");

            if (root.Element("DistributedEsb").Element("WebSessionSupport") != null
                && root.Element("DistributedEsb").Element("WebSessionSupport").Value != null
                && root.Element("DistributedEsb").Element("WebSessionSupport").Value.Trim().Length > 0)
                WebSessionSupport = bool.Parse(root.Element("DistributedEsb").Element("WebSessionSupport").Value);
            else
                WebSessionSupport = true;//default support session transfer
        }
    }
}
